/*
 * CS 567 GUI - Semester Project - "DecisionLists"
 * Jason Frank
 * Spring 2011
 *
 * This File:  AddItemForm.java
 *
 */

package Decision_Lists;

import com.thebuzzmedia.imgscalr.Scalr;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/*
 */
public class AddItemForm extends JPanel implements DL_ViewInterface {

  ///////////////////////////
  //// CLASS VARS ///////////
  protected String viewName = "AddItemForm";
  DL_Model model;
  protected final String DEFAULT_PIC_FILENAME = "media/DefaultHouseImage.jpg";
  protected final int MAIN_PIC_PREV_SIZE = 150;  // # pixels to resize pic to for preview display
  protected int price;

  String mainPicFilename, locationPicFilename;

  Font font_plain14Helv = new Font("Helvetica", Font.PLAIN, 14); // suitable for textfields
  Font font_plain12Helv = new Font("Helvetica", Font.PLAIN, 12); // suitable for textareas

  // components that should be hidden & unhidden. The 'reset' method hides all such components to get the view back to orig
  Vector <Component> hideableCompVec = new Vector<Component>();

  Vector <Component> startsVisibleCompVec = new Vector<Component>();

  int prosCount = 1;
  int consCount = 1;
  //// end Class Vars ////////
  ////////////////////////////

    // Constructor
  public AddItemForm(DL_Model model)  {

      this.model = model;

      initComponents(); // does the layout of the generated items
      // TWEAK THE COMPONENTS
      // a hack to get Java to stop overrighting my initial text an to stop it from automatically giving it focus
      nameField.setFocusable(false); // works sometimes
      nameField.setFocusable(true); // works sometimes
      // Main Pic
      mainPicPreviewLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
      mainPicPreviewLabel.setVisible(false);
      hideableCompVec.add(mainPicPreviewLabel);
      hideableCompVec.add(mainPicPreviewLabelContainer);
      // Location Pic
      locationPicPreviewLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
      locationPicPreviewLabel.setVisible(false);
      hideableCompVec.add(locationPicPreviewLabel);
      hideableCompVec.add(locationPicPreviewLabelContainer);
      // Pros
      pro1DetailPanel.setVisible(false);
      hideableCompVec.add(pro1DetailPanel);

      pro2Panel.setVisible(false);
      hideableCompVec.add(pro2Panel);
      // Add the "Add another Pro" btn to the list of components that should start out visible
      startsVisibleCompVec.add(addAnotherProBtn);

      // Cons
      con1DetailPanel.setVisible(false);
      hideableCompVec.add(con1DetailPanel);

      con2Panel.setVisible(false);
      hideableCompVec.add(con2Panel);
      // Add the "Add another Con" btn to the list of components that should start out visible
      startsVisibleCompVec.add(addAnotherConBtn);

  } ///////////// end constructor /////////////

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jScrollPane6 = new javax.swing.JScrollPane();
    containerPanel = new javax.swing.JPanel();
    locationPicLabel = new javax.swing.JLabel();
    addAnotherProBtn = new javax.swing.JButton();
    mainPicPreviewLabelContainer = new javax.swing.JLabel();
    mainPicPreviewLabel = new javax.swing.JLabel();
    locationPicPreviewLabel = new javax.swing.JLabel();
    LocationFileChooserBtn = new javax.swing.JButton();
    pro1DetailPanel = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    proDetail1Textarea1 = new javax.swing.JTextArea();
    proDetail1Label1 = new javax.swing.JLabel();
    locationPicPreviewLabelContainer = new javax.swing.JLabel();
    priceLabel = new javax.swing.JLabel();
    priceField = new javax.swing.JTextField();
    summaryLabel = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    summaryTextarea = new javax.swing.JTextArea();
    proTitle1Label = new javax.swing.JLabel();
    addListItemLabel = new javax.swing.JLabel();
    addListItemLabel1 = new javax.swing.JLabel();
    mainPicLabel = new javax.swing.JLabel();
    proTitle1Field = new javax.swing.JTextField();
    nameField = new javax.swing.JTextField();
    nameLabel = new javax.swing.JLabel();
    pro2Panel = new javax.swing.JPanel();
    pro2DetailPanel = new javax.swing.JPanel();
    jScrollPane4 = new javax.swing.JScrollPane();
    proDetail2Textarea1 = new javax.swing.JTextArea();
    proDetail1Label2 = new javax.swing.JLabel();
    proTitle1Label1 = new javax.swing.JLabel();
    proTitle2Field = new javax.swing.JTextField();
    mainPicFileChooserBtn = new javax.swing.JButton();
    conTitle1Label = new javax.swing.JLabel();
    conTitle1Field = new javax.swing.JTextField();
    addAnotherConBtn = new javax.swing.JButton();
    con1DetailPanel = new javax.swing.JPanel();
    jScrollPane3 = new javax.swing.JScrollPane();
    conDetail1Textarea1 = new javax.swing.JTextArea();
    conDetail1Label1 = new javax.swing.JLabel();
    con2Panel = new javax.swing.JPanel();
    pro2DetailPanel1 = new javax.swing.JPanel();
    jScrollPane5 = new javax.swing.JScrollPane();
    conDetail2Textarea1 = new javax.swing.JTextArea();
    conDetail2Label1 = new javax.swing.JLabel();
    conTitle2Label = new javax.swing.JLabel();
    conTitle2Field = new javax.swing.JTextField();

    setAutoscrolls(true);

    locationPicLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
    locationPicLabel.setText("Location Pic:");

    addAnotherProBtn.setText("[Add another pro]");
    addAnotherProBtn.setBorder(null);
    addAnotherProBtn.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        addAnotherProBtnActionPerformed(evt);
      }
    });

    mainPicPreviewLabelContainer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

    mainPicPreviewLabel.setText("Main Pic Preview:");

    locationPicPreviewLabel.setText("Loc. Pic Preview:");

    LocationFileChooserBtn.setFont(new java.awt.Font("Arial", 0, 11));
    LocationFileChooserBtn.setText("Choose File");
    LocationFileChooserBtn.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        LocationFileChooserBtnActionPerformed(evt);
      }
    });

    jScrollPane2.setAutoscrolls(true);

    proDetail1Textarea1.setColumns(16);
    proDetail1Textarea1.setFont(new java.awt.Font("Tahoma", 0, 10));
    proDetail1Textarea1.setForeground(new java.awt.Color(132, 132, 132));
    proDetail1Textarea1.setLineWrap(true);
    proDetail1Textarea1.setRows(5);
    proDetail1Textarea1.setText("A sentence or two providing details");
    proDetail1Textarea1.setToolTipText("A sentence or two providing details");
    proDetail1Textarea1.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        proDetail1Textarea1FocusGained(evt);
      }
    });
    jScrollPane2.setViewportView(proDetail1Textarea1);

    proDetail1Label1.setFont(new java.awt.Font("Tahoma", 0, 14));
    proDetail1Label1.setText("Pro detail:");

    javax.swing.GroupLayout pro1DetailPanelLayout = new javax.swing.GroupLayout(pro1DetailPanel);
    pro1DetailPanel.setLayout(pro1DetailPanelLayout);
    pro1DetailPanelLayout.setHorizontalGroup(
      pro1DetailPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pro1DetailPanelLayout.createSequentialGroup()
        .addComponent(proDetail1Label1)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
    pro1DetailPanelLayout.setVerticalGroup(
      pro1DetailPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(proDetail1Label1)
    );

    locationPicPreviewLabelContainer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

    priceLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
    priceLabel.setText("Price:");

    priceField.setFont(new java.awt.Font("Tahoma", 0, 10));
    priceField.setForeground(new java.awt.Color(125, 125, 125));
    priceField.setText("Show me the money!");
    priceField.setToolTipText("Show me the money!!!");
    priceField.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        priceFieldMouseClicked(evt);
      }
    });
    priceField.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        priceFieldActionPerformed(evt);
      }
    });
    priceField.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        priceFieldFocusGained(evt);
      }
      public void focusLost(java.awt.event.FocusEvent evt) {
        priceFieldFocusLost(evt);
      }
    });

    summaryLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
    summaryLabel.setText("Summary:");

    jScrollPane1.setAutoscrolls(true);

    summaryTextarea.setColumns(16);
    summaryTextarea.setFont(new java.awt.Font("Arial", 0, 12));
    summaryTextarea.setLineWrap(true);
    summaryTextarea.setRows(5);
    jScrollPane1.setViewportView(summaryTextarea);

    proTitle1Label.setFont(new java.awt.Font("Tahoma", 0, 14));
    proTitle1Label.setText("Pro #1 Title:");

    addListItemLabel.setFont(new java.awt.Font("Arial", 1, 19));
    addListItemLabel.setText("Add a List Item");

    addListItemLabel1.setFont(new java.awt.Font("Arial", 1, 14));
    addListItemLabel1.setText("Pros and Cons");

    mainPicLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
    mainPicLabel.setText("Main Pic:");

    proTitle1Field.setFont(new java.awt.Font("Tahoma", 0, 10));
    proTitle1Field.setForeground(new java.awt.Color(132, 132, 132));
    proTitle1Field.setText("A word or short phrase describing this pro");
    proTitle1Field.setToolTipText("A word or short phrase describing this pro");
    proTitle1Field.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        proTitle1FieldMouseClicked(evt);
      }
    });
    proTitle1Field.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        proTitle1FieldActionPerformed(evt);
      }
    });
    proTitle1Field.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        proTitle1FieldFocusGained(evt);
      }
      public void focusLost(java.awt.event.FocusEvent evt) {
        proTitle1FieldFocusLost(evt);
      }
    });

    nameField.setFont(new java.awt.Font("Tahoma", 0, 10));
    nameField.setForeground(new java.awt.Color(132, 132, 132));
    nameField.setText("A word or short phrase describing this house");
    nameField.setToolTipText("A word or short phrase describing this house");
    nameField.setAutoscrolls(false);
    nameField.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        nameFieldMouseClicked(evt);
      }
    });
    nameField.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        nameFieldActionPerformed(evt);
      }
    });
    nameField.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        nameFieldFocusGained(evt);
      }
    });

    nameLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
    nameLabel.setText("Name:");

    jScrollPane4.setAutoscrolls(true);

    proDetail2Textarea1.setColumns(16);
    proDetail2Textarea1.setFont(new java.awt.Font("Tahoma", 0, 10));
    proDetail2Textarea1.setForeground(new java.awt.Color(132, 132, 132));
    proDetail2Textarea1.setLineWrap(true);
    proDetail2Textarea1.setRows(5);
    proDetail2Textarea1.setText("A sentence or two providing details");
    proDetail2Textarea1.setToolTipText("A sentence or two providing details");
    proDetail2Textarea1.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        proDetail2Textarea1FocusGained(evt);
      }
    });
    jScrollPane4.setViewportView(proDetail2Textarea1);

    proDetail1Label2.setFont(new java.awt.Font("Tahoma", 0, 14));
    proDetail1Label2.setText("Pro detail:");

    javax.swing.GroupLayout pro2DetailPanelLayout = new javax.swing.GroupLayout(pro2DetailPanel);
    pro2DetailPanel.setLayout(pro2DetailPanelLayout);
    pro2DetailPanelLayout.setHorizontalGroup(
      pro2DetailPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pro2DetailPanelLayout.createSequentialGroup()
        .addComponent(proDetail1Label2)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
    pro2DetailPanelLayout.setVerticalGroup(
      pro2DetailPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(proDetail1Label2)
    );

    proTitle1Label1.setFont(new java.awt.Font("Tahoma", 0, 14));
    proTitle1Label1.setText("Pro #2 Title:");

    proTitle2Field.setFont(new java.awt.Font("Tahoma", 0, 10));
    proTitle2Field.setForeground(new java.awt.Color(132, 132, 132));
    proTitle2Field.setText("A word or short phrase describing this pro");
    proTitle2Field.setToolTipText("A word or short phrase describing this pro");
    proTitle2Field.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        proTitle2FieldMouseClicked(evt);
      }
    });
    proTitle2Field.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        proTitle2FieldActionPerformed(evt);
      }
    });
    proTitle2Field.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        proTitle2FieldFocusGained(evt);
      }
      public void focusLost(java.awt.event.FocusEvent evt) {
        proTitle2FieldFocusLost(evt);
      }
    });

    javax.swing.GroupLayout pro2PanelLayout = new javax.swing.GroupLayout(pro2Panel);
    pro2Panel.setLayout(pro2PanelLayout);
    pro2PanelLayout.setHorizontalGroup(
      pro2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(pro2PanelLayout.createSequentialGroup()
        .addGap(31, 31, 31)
        .addComponent(proTitle1Label1)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(proTitle2Field, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(pro2DetailPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    pro2PanelLayout.setVerticalGroup(
      pro2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(pro2PanelLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(pro2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(pro2DetailPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addGroup(pro2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
            .addComponent(proTitle2Field, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(proTitle1Label1)))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    mainPicFileChooserBtn.setFont(new java.awt.Font("Arial", 0, 11));
    mainPicFileChooserBtn.setText("Choose File");
    mainPicFileChooserBtn.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        mainPicFileChooserBtnActionPerformed(evt);
      }
    });

    conTitle1Label.setFont(new java.awt.Font("Tahoma", 0, 14));
    conTitle1Label.setText("Con #1 Title:");

    conTitle1Field.setFont(new java.awt.Font("Tahoma", 0, 10));
    conTitle1Field.setForeground(new java.awt.Color(132, 132, 132));
    conTitle1Field.setText("A word or short phrase describing this con");
    conTitle1Field.setToolTipText("A word or short phrase describing this con");
    conTitle1Field.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        conTitle1FieldMouseClicked(evt);
      }
    });
    conTitle1Field.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        conTitle1FieldActionPerformed(evt);
      }
    });
    conTitle1Field.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        conTitle1FieldFocusGained(evt);
      }
      public void focusLost(java.awt.event.FocusEvent evt) {
        conTitle1FieldFocusLost(evt);
      }
    });

    addAnotherConBtn.setText("[Add another con]");
    addAnotherConBtn.setBorder(null);
    addAnotherConBtn.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        addAnotherConBtnActionPerformed(evt);
      }
    });

    jScrollPane3.setAutoscrolls(true);

    conDetail1Textarea1.setColumns(16);
    conDetail1Textarea1.setFont(new java.awt.Font("Tahoma", 0, 10));
    conDetail1Textarea1.setForeground(new java.awt.Color(132, 132, 132));
    conDetail1Textarea1.setLineWrap(true);
    conDetail1Textarea1.setRows(5);
    conDetail1Textarea1.setText("A sentence or two providing details");
    conDetail1Textarea1.setToolTipText("A sentence or two providing details");
    conDetail1Textarea1.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        conDetail1Textarea1FocusGained(evt);
      }
    });
    jScrollPane3.setViewportView(conDetail1Textarea1);

    conDetail1Label1.setFont(new java.awt.Font("Tahoma", 0, 14));
    conDetail1Label1.setText("Con detail:");

    javax.swing.GroupLayout con1DetailPanelLayout = new javax.swing.GroupLayout(con1DetailPanel);
    con1DetailPanel.setLayout(con1DetailPanelLayout);
    con1DetailPanelLayout.setHorizontalGroup(
      con1DetailPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, con1DetailPanelLayout.createSequentialGroup()
        .addComponent(conDetail1Label1)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
    con1DetailPanelLayout.setVerticalGroup(
      con1DetailPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(conDetail1Label1)
    );

    jScrollPane5.setAutoscrolls(true);

    conDetail2Textarea1.setColumns(16);
    conDetail2Textarea1.setFont(new java.awt.Font("Tahoma", 0, 10));
    conDetail2Textarea1.setForeground(new java.awt.Color(132, 132, 132));
    conDetail2Textarea1.setLineWrap(true);
    conDetail2Textarea1.setRows(5);
    conDetail2Textarea1.setText("A sentence or two providing details");
    conDetail2Textarea1.setToolTipText("A sentence or two providing details");
    conDetail2Textarea1.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        conDetail2Textarea1FocusGained(evt);
      }
    });
    jScrollPane5.setViewportView(conDetail2Textarea1);

    conDetail2Label1.setFont(new java.awt.Font("Tahoma", 0, 14));
    conDetail2Label1.setText("Con detail:");

    javax.swing.GroupLayout pro2DetailPanel1Layout = new javax.swing.GroupLayout(pro2DetailPanel1);
    pro2DetailPanel1.setLayout(pro2DetailPanel1Layout);
    pro2DetailPanel1Layout.setHorizontalGroup(
      pro2DetailPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pro2DetailPanel1Layout.createSequentialGroup()
        .addComponent(conDetail2Label1)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
    pro2DetailPanel1Layout.setVerticalGroup(
      pro2DetailPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(conDetail2Label1)
    );

    conTitle2Label.setFont(new java.awt.Font("Tahoma", 0, 14));
    conTitle2Label.setText("Con #2 Title:");

    conTitle2Field.setFont(new java.awt.Font("Tahoma", 0, 10));
    conTitle2Field.setForeground(new java.awt.Color(132, 132, 132));
    conTitle2Field.setText("A word or short phrase describing this con");
    conTitle2Field.setToolTipText("A word or short phrase describing this con");
    conTitle2Field.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        conTitle2FieldMouseClicked(evt);
      }
    });
    conTitle2Field.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        conTitle2FieldActionPerformed(evt);
      }
    });
    conTitle2Field.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusGained(java.awt.event.FocusEvent evt) {
        conTitle2FieldFocusGained(evt);
      }
      public void focusLost(java.awt.event.FocusEvent evt) {
        conTitle2FieldFocusLost(evt);
      }
    });

    javax.swing.GroupLayout con2PanelLayout = new javax.swing.GroupLayout(con2Panel);
    con2Panel.setLayout(con2PanelLayout);
    con2PanelLayout.setHorizontalGroup(
      con2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(con2PanelLayout.createSequentialGroup()
        .addGap(31, 31, 31)
        .addComponent(conTitle2Label)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(conTitle2Field, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(pro2DetailPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGap(18, 18, 18))
    );
    con2PanelLayout.setVerticalGroup(
      con2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(con2PanelLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(con2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(pro2DetailPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addGroup(con2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
            .addComponent(conTitle2Field, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(conTitle2Label)))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout containerPanelLayout = new javax.swing.GroupLayout(containerPanel);
    containerPanel.setLayout(containerPanelLayout);
    containerPanelLayout.setHorizontalGroup(
      containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(containerPanelLayout.createSequentialGroup()
        .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(containerPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(containerPanelLayout.createSequentialGroup()
                  .addGap(16, 16, 16)
                  .addComponent(addListItemLabel))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, containerPanelLayout.createSequentialGroup()
                  .addGap(28, 28, 28)
                  .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(mainPicLabel)
                    .addComponent(nameLabel)
                    .addComponent(locationPicLabel))
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                  .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(containerPanelLayout.createSequentialGroup()
                      .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(nameField, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, containerPanelLayout.createSequentialGroup()
                          .addComponent(mainPicFileChooserBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addGap(18, 18, 18)
                          .addComponent(mainPicPreviewLabel)))
                      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                      .addComponent(mainPicPreviewLabelContainer, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(containerPanelLayout.createSequentialGroup()
                      .addComponent(LocationFileChooserBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addGap(18, 18, 18)
                      .addComponent(locationPicPreviewLabel)
                      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                      .addComponent(locationPicPreviewLabelContainer, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)))
                  .addGap(139, 139, 139)))
              .addGroup(containerPanelLayout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                  .addComponent(priceLabel)
                  .addComponent(summaryLabel)
                  .addComponent(addListItemLabel1)
                  .addComponent(proTitle1Label))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(priceField)
                    .addComponent(jScrollPane1)
                    .addComponent(proTitle1Field, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE))
                  .addComponent(addAnotherProBtn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pro1DetailPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
              .addComponent(pro2Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
          .addGroup(containerPanelLayout.createSequentialGroup()
            .addGap(39, 39, 39)
            .addComponent(conTitle1Label)
            .addGap(12, 12, 12)
            .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(addAnotherConBtn)
              .addComponent(conTitle1Field, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(con1DetailPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
          .addGroup(containerPanelLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(con2Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        .addContainerGap(61, Short.MAX_VALUE))
    );
    containerPanelLayout.setVerticalGroup(
      containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(containerPanelLayout.createSequentialGroup()
        .addGap(24, 24, 24)
        .addComponent(addListItemLabel)
        .addGap(18, 18, 18)
        .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(nameLabel)
          .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(mainPicLabel)
            .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
              .addComponent(mainPicFileChooserBtn)
              .addComponent(mainPicPreviewLabel)))
          .addComponent(mainPicPreviewLabelContainer, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(containerPanelLayout.createSequentialGroup()
            .addGap(18, 18, 18)
            .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(locationPicPreviewLabelContainer, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
              .addComponent(locationPicPreviewLabel)))
          .addGroup(containerPanelLayout.createSequentialGroup()
            .addGap(11, 11, 11)
            .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
              .addComponent(locationPicLabel)
              .addComponent(LocationFileChooserBtn))))
        .addGap(18, 18, 18)
        .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(priceLabel)
          .addComponent(priceField, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(containerPanelLayout.createSequentialGroup()
            .addComponent(summaryLabel)
            .addGap(52, 52, 52)
            .addComponent(addListItemLabel1))
          .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(containerPanelLayout.createSequentialGroup()
            .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
              .addComponent(proTitle1Label)
              .addComponent(proTitle1Field, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(addAnotherProBtn))
          .addComponent(pro1DetailPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(pro2Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGap(26, 26, 26)
        .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addGroup(containerPanelLayout.createSequentialGroup()
            .addGroup(containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
              .addComponent(conTitle1Label)
              .addComponent(conTitle1Field, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(addAnotherConBtn))
          .addComponent(con1DetailPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(con2Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGap(26, 26, 26))
    );

    jScrollPane6.setViewportView(containerPanel);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 729, Short.MAX_VALUE)
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(933, Short.MAX_VALUE))
    );
  }// </editor-fold>//GEN-END:initComponents


    // Blanks out the text field of the event passed in (clearing direction text) and sets font
    //  to black, size 14 Helvetica
    private void textFieldFocusGainedHandler(MouseEvent evt) {

      JTextField textField = (JTextField) evt.getSource();
      // Remove the direction text once the user clicks in the field (so they can type their own text)
      textField.setText("");
      // Make the new text they type black and bigger
      textField.setForeground(Color.black);
      textField.setFont(font_plain14Helv);
    } //////// end textFieldFocusGainedHandler() ///////////

    // OVERLOADED METHOD
    // Blanks out the text field of the event passed in (clearing direction text) and sets font
    //  to black, size 14 Helvetica
    private void textFieldFocusGainedHandler(FocusEvent evt) {

      JTextField textField = (JTextField) evt.getSource();
      // Remove the direction text once the user clicks in the field (so they can type their own text)
      textField.setText("");
      // Make the new text they type black and bigger
      textField.setForeground(Color.black);
      textField.setFont(font_plain14Helv);
    } //////// end textFieldFocusGainedHandler() ///////////



    private void nameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameFieldActionPerformed
      
    }//GEN-LAST:event_nameFieldActionPerformed

    private void mainPicFileChooserBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mainPicFileChooserBtnActionPerformed

      JFileChooser fc = new JFileChooser();
      fc.setAccessory(new ImagePreview(fc));
      int fcRetVal = fc.showOpenDialog(this);

      if(fcRetVal == JFileChooser.APPROVE_OPTION) {
          File file = fc.getSelectedFile();
          mainPicFilename = file.getAbsolutePath(); // save the filename for adding pic to model

                  //System.out.println("Ready to open: " + file.getName() + "." + "\n");
          // read in the image file from disk, put it into a buffered image that is painted to a JPanel
          ImagePanel imagePanel = new ImagePanel(file);
          // resize the image so it roughly fits in preview area
          BufferedImage resizedPic = Scalr.resize(imagePanel.getBufferedImage(), MAIN_PIC_PREV_SIZE);
          // Put the image in the label that I'm using like a containter
          mainPicPreviewLabelContainer.setIcon(new ImageIcon(resizedPic));
          // Make the "Main Pic Preview" label visible
          mainPicPreviewLabel.setVisible(true);
          mainPicPreviewLabelContainer.setVisible(true);
      }
      else {
          System.out.println("Open command canceled by user." + "\n");
      }
    }//GEN-LAST:event_mainPicFileChooserBtnActionPerformed


    private void nameFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nameFieldMouseClicked

      textFieldFocusGainedHandler(evt);
    }//GEN-LAST:event_nameFieldMouseClicked


    private void LocationFileChooserBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LocationFileChooserBtnActionPerformed
      
      JFileChooser fc = new JFileChooser();
      fc.setAccessory(new ImagePreview(fc));
      int fcRetVal = fc.showOpenDialog(this);

      if(fcRetVal == JFileChooser.APPROVE_OPTION) {
          File file = fc.getSelectedFile();
          locationPicFilename = file.getAbsolutePath(); // save the filename for adding pic to model

                  //System.out.println("Ready to open: " + file.getName() + "." + "\n");
          // read in the image file from disk, put it into a buffered image that is painted to a JPanel
          ImagePanel imagePanel = new ImagePanel(file);
          // resize the image so it roughly fits in preview area
          BufferedImage resizedPic = Scalr.resize(imagePanel.getBufferedImage(), MAIN_PIC_PREV_SIZE);
          // Put the image in the label that I'm using like a containter
          locationPicPreviewLabelContainer.setIcon(new ImageIcon(resizedPic));
          // Make the "Main Pic Preview" label visible
          locationPicPreviewLabel.setVisible(true);
          locationPicPreviewLabelContainer.setVisible(true);
      }
      else {
          System.out.println("Open command canceled by user." + "\n");
      }
    }//GEN-LAST:event_LocationFileChooserBtnActionPerformed

    private void priceFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_priceFieldMouseClicked

      JTextField textField = (JTextField) evt.getSource();
      // Remove the direction text once the user clicks in the field (so they can type their own text)
      textField.setText("$");
      // Make the new text they type black and bigger
      textField.setForeground(Color.black);
      textField.setFont(font_plain14Helv);
    }//GEN-LAST:event_priceFieldMouseClicked

    private void priceFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_priceFieldActionPerformed

    }//GEN-LAST:event_priceFieldActionPerformed

    private void priceFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_priceFieldFocusLost

      String priceStrNoDollarSign = priceField.getText().substring(1);
      try {
        price = Integer.parseInt(priceStrNoDollarSign);
      } catch(Exception e) {
                  // Couldn't get this to work:
                  //      SwingUtilities.invokeLater( new Runnable() { // http://stackoverflow.com/questions/1178312/how-to-select-all-text-in-a-jformattedtextfield-when-it-gets-focus
                  //          @Override
                  //          public void run() {
                  //            //priceField.select(1, 100);
                  //            priceField.selectAll();
                  //          }
                  //      });
          //priceField.select(1, 100);
          JOptionPane.showMessageDialog(this, "You must enter an integer into the price field.",
                                       "Error", JOptionPane.ERROR_MESSAGE);
      }
    }//GEN-LAST:event_priceFieldFocusLost

    private void proTitle1FieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_proTitle1FieldMouseClicked
      // TODO add your handling code here:
    }//GEN-LAST:event_proTitle1FieldMouseClicked

    private void proTitle1FieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_proTitle1FieldActionPerformed
      // TODO add your handling code here:
    }//GEN-LAST:event_proTitle1FieldActionPerformed

    private void proTitle1FieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_proTitle1FieldFocusLost
      // TODO add your handling code here:
    }//GEN-LAST:event_proTitle1FieldFocusLost

    private void nameFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_nameFieldFocusGained
      
      textFieldFocusGainedHandler(evt);
    }//GEN-LAST:event_nameFieldFocusGained

    private void priceFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_priceFieldFocusGained
      JTextField textField = (JTextField) evt.getSource();
      // Remove the direction text once the user clicks in the field (so they can type their own text)
      textField.setText("$");
      // Make the new text they type black and bigger
      textField.setForeground(Color.black);
      textField.setFont(font_plain14Helv);
    }//GEN-LAST:event_priceFieldFocusGained

    private void proTitle1FieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_proTitle1FieldFocusGained
      textFieldFocusGainedHandler(evt);
      //proDetail1Label1.setVisible(true);
      //proDetail1Textarea1.setVisible(true);
      pro1DetailPanel.setVisible(true);
    }//GEN-LAST:event_proTitle1FieldFocusGained

    private void proDetail1Textarea1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_proDetail1Textarea1FocusGained
      JTextArea textArea = (JTextArea) evt.getSource();
      // Remove the direction text once the user clicks in the field (so they can type their own text)
      textArea.setText("");
      // Make the new text they type black and bigger
      textArea.setForeground(Color.black);
      textArea.setFont(font_plain12Helv);
    }//GEN-LAST:event_proDetail1Textarea1FocusGained

    private void proDetail2Textarea1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_proDetail2Textarea1FocusGained
      proDetail1Textarea1FocusGained(evt);
    }//GEN-LAST:event_proDetail2Textarea1FocusGained

    private void proTitle2FieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_proTitle2FieldMouseClicked
      // TODO add your handling code here:
    }//GEN-LAST:event_proTitle2FieldMouseClicked

    private void proTitle2FieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_proTitle2FieldActionPerformed
      // TODO add your handling code here:
    }//GEN-LAST:event_proTitle2FieldActionPerformed

    private void proTitle2FieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_proTitle2FieldFocusGained
      proTitle1FieldFocusGained(evt);
    }//GEN-LAST:event_proTitle2FieldFocusGained

    private void proTitle2FieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_proTitle2FieldFocusLost
      // TODO add your handling code here:
    }//GEN-LAST:event_proTitle2FieldFocusLost

    private void addAnotherProBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addAnotherProBtnActionPerformed
      prosCount++;
      pro2Panel.setVisible(true);
      addAnotherProBtn.setVisible(false);
      //startsVisibleCompVec.add(addAnotherProBtn);
    }//GEN-LAST:event_addAnotherProBtnActionPerformed

    private void conTitle1FieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_conTitle1FieldMouseClicked
      // TODO add your handling code here:
    }//GEN-LAST:event_conTitle1FieldMouseClicked

    private void conTitle1FieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_conTitle1FieldActionPerformed
      // TODO add your handling code here:
    }//GEN-LAST:event_conTitle1FieldActionPerformed

    private void conTitle1FieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_conTitle1FieldFocusGained
      textFieldFocusGainedHandler(evt);
      con1DetailPanel.setVisible(true);
    }//GEN-LAST:event_conTitle1FieldFocusGained

    private void conTitle1FieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_conTitle1FieldFocusLost
      // TODO add your handling code here:
    }//GEN-LAST:event_conTitle1FieldFocusLost

    private void addAnotherConBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addAnotherConBtnActionPerformed
      consCount++;
      con2Panel.setVisible(true);
      // Make the "Add another con" button go away
      ((JButton)(evt.getSource())).setVisible(false);
    }//GEN-LAST:event_addAnotherConBtnActionPerformed

    private void conDetail1Textarea1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_conDetail1Textarea1FocusGained
      JTextArea textArea = (JTextArea) evt.getSource();
      // Remove the direction text once the user clicks in the field (so they can type their own text)
      textArea.setText("");
      // Make the new text they type black and bigger
      textArea.setForeground(Color.black);
      textArea.setFont(font_plain12Helv);
    }//GEN-LAST:event_conDetail1Textarea1FocusGained

    private void conDetail2Textarea1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_conDetail2Textarea1FocusGained
      JTextArea textArea = (JTextArea) evt.getSource();
      // Remove the direction text once the user clicks in the field (so they can type their own text)
      textArea.setText("");
      // Make the new text they type black and bigger
      textArea.setForeground(Color.black);
      textArea.setFont(font_plain12Helv);
    }//GEN-LAST:event_conDetail2Textarea1FocusGained

    private void conTitle2FieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_conTitle2FieldMouseClicked
      // TODO add your handling code here:
    }//GEN-LAST:event_conTitle2FieldMouseClicked

    private void conTitle2FieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_conTitle2FieldActionPerformed
      // TODO add your handling code here:
    }//GEN-LAST:event_conTitle2FieldActionPerformed

    private void conTitle2FieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_conTitle2FieldFocusGained
      textFieldFocusGainedHandler(evt);
    }//GEN-LAST:event_conTitle2FieldFocusGained

    private void conTitle2FieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_conTitle2FieldFocusLost
      // TODO add your handling code here:
    }//GEN-LAST:event_conTitle2FieldFocusLost


  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton LocationFileChooserBtn;
  private javax.swing.JButton addAnotherConBtn;
  private javax.swing.JButton addAnotherProBtn;
  private javax.swing.JLabel addListItemLabel;
  private javax.swing.JLabel addListItemLabel1;
  private javax.swing.JPanel con1DetailPanel;
  private javax.swing.JPanel con2Panel;
  private javax.swing.JLabel conDetail1Label1;
  private javax.swing.JTextArea conDetail1Textarea1;
  private javax.swing.JLabel conDetail2Label1;
  private javax.swing.JTextArea conDetail2Textarea1;
  private javax.swing.JTextField conTitle1Field;
  private javax.swing.JLabel conTitle1Label;
  private javax.swing.JTextField conTitle2Field;
  private javax.swing.JLabel conTitle2Label;
  private javax.swing.JPanel containerPanel;
  private javax.swing.JScrollPane jScrollPane1;
  private javax.swing.JScrollPane jScrollPane2;
  private javax.swing.JScrollPane jScrollPane3;
  private javax.swing.JScrollPane jScrollPane4;
  private javax.swing.JScrollPane jScrollPane5;
  private javax.swing.JScrollPane jScrollPane6;
  private javax.swing.JLabel locationPicLabel;
  private javax.swing.JLabel locationPicPreviewLabel;
  private javax.swing.JLabel locationPicPreviewLabelContainer;
  private javax.swing.JButton mainPicFileChooserBtn;
  private javax.swing.JLabel mainPicLabel;
  private javax.swing.JLabel mainPicPreviewLabel;
  private javax.swing.JLabel mainPicPreviewLabelContainer;
  private javax.swing.JTextField nameField;
  private javax.swing.JLabel nameLabel;
  private javax.swing.JTextField priceField;
  private javax.swing.JLabel priceLabel;
  private javax.swing.JPanel pro1DetailPanel;
  private javax.swing.JPanel pro2DetailPanel;
  private javax.swing.JPanel pro2DetailPanel1;
  private javax.swing.JPanel pro2Panel;
  private javax.swing.JLabel proDetail1Label1;
  private javax.swing.JLabel proDetail1Label2;
  private javax.swing.JTextArea proDetail1Textarea1;
  private javax.swing.JTextArea proDetail2Textarea1;
  private javax.swing.JTextField proTitle1Field;
  private javax.swing.JLabel proTitle1Label;
  private javax.swing.JLabel proTitle1Label1;
  private javax.swing.JTextField proTitle2Field;
  private javax.swing.JLabel summaryLabel;
  private javax.swing.JTextArea summaryTextarea;
  // End of variables declaration//GEN-END:variables


  public void saveItemToModel() throws IOException {

    List_Item_Data item = new List_Item_Data();
    item.setName(nameField.getText());
    if(mainPicFilename == null) {
      item.setMainPic(DEFAULT_PIC_FILENAME);
    }
    else {
      item.setMainPic(mainPicFilename);
    }
    if(locationPicFilename == null) {
      item.setLocationPic(DEFAULT_PIC_FILENAME);
    }
    else {
      item.setLocationPic(locationPicFilename);
    }
    //String priceStrNoDollarSign = priceField.getText().substring(1);
    item.setPrice(price);
    item.setSummary(summaryTextarea.getText());

    // ADD PROS
    // Pro #1
    List_Item_Data.ProCon pro = item.new ProCon();
    pro.setMainPhrase(proTitle1Field.getText());
    pro.addDetail(proDetail1Textarea1.getText());

    item.addPro(pro);
    // Pro #2 (if necessary)
    if(prosCount > 1) {
      pro = item.new ProCon();
      pro.setMainPhrase(proTitle2Field.getText());
      pro.addDetail(proDetail2Textarea1.getText());
      item.addPro(pro);
    }

    // ADD CONS
    // Con #1
    List_Item_Data.ProCon con = item.new ProCon();
    con.setMainPhrase(conTitle1Field.getText());
    con.addDetail(conDetail1Textarea1.getText());
    item.addCon(con);
    // Con #2 (if necessary)
    if(consCount > 1) {
      con = item.new ProCon();
      con.setMainPhrase(conTitle2Field.getText());
      con.addDetail(conDetail2Textarea1.getText());
      item.addCon(con);
    }

//    ///// TEMP CODE - to complete a list item for testing ////////
//
//    // Add Cons
//    List_Item_Data.ProCon con = item.new ProCon();
//    con.setMainPhrase("Con 1");
//    con.addDetail("Here is some detail about this con."
//            + "");
//    item.addCon(con);
//
//    con = item.new ProCon();
//    con.setMainPhrase("Con 2");
//    con.addDetail("I don't like having any Cons, but I guess that's the way it goes, huh?"
//            + "");
//    item.addCon(con);

    ////// end temp code /////////////////////////////////////
    //////////////////////////////////////////////////////////


    model.addNewItem(item);
    
  } ////// end saveItemToModel() //////////////


  ///////////////////////////////////////////
  //// METHODS REQUIRED BY THE INTERFACE ////
  public void curViewChanged(String old_view_name, String new_view_name) {
  }
  // Model calls this to inform views of an added (new) list item.
  //  The views will then probably need to re-layout their list items to reflect the change.
  public void itemAdded(List_Item_Data newItem) {
    // Do nothing
  }

  // Model calls this to inform views of a changed list item (i.e., new item added, old item deleted, etc).
  //  The views will then probably need to re-layout their list items to reflect the change.
  public void itemChanged() {
    // Do nothing.
  }

  public String getViewName() {
    return viewName;
  }

  ///// end methods required by the interface /////
  /////////////////////////////////////////////////


  /////////////////////////////////////////////////////////////////////////////
  // Nested class for making Images into JPanels for easier layouts
  // Got idea from: http://stackoverflow.com/questions/299495/java-swing-how-to-add-an-image-to-a-jpanel
  private class ImagePanel extends JPanel{

    private BufferedImage image;
    // Constructor #1
    public ImagePanel(String picFilename) throws IOException {
      // Try to open the user's image. If that fails, try to open the default image. If that fails, exit.
      try {
          image = ImageIO.read(new File(picFilename));
       } catch (IOException e) {
            System.err.println(e);
            System.err.println("\nCould not open your pic file \"" + picFilename
                               + "\", using a default image instead.");
            try {
              image = ImageIO.read(new File(DEFAULT_PIC_FILENAME));
            } catch (IOException ex) {
                System.err.println(ex);
                System.err.println("\nCould not open the default pic file, exiting.");
                System.exit(-1);
            } // end inner catch
       } // end outer catch

    } // end constructor #1

    // Constructor #2
    private ImagePanel(File file) {
      // Try to open the user's image. If that fails, try to open the default image. If that fails, exit.
      try {
          image = ImageIO.read(file);
       } catch (IOException e) {
            System.err.println(e);
            System.err.println("\nCould not open your pic file \"" + file.getName()
                               + "\", using a default image instead.");
            try {
              image = ImageIO.read(new File(DEFAULT_PIC_FILENAME));
            } catch (IOException ex) {
                System.err.println(ex);
                System.err.println("\nCould not open the default pic file, exiting.");
                System.exit(-1);
            } // end inner catch
       } // end outer catch
    } // end constructor #2

    @Override
    public void paintComponent(Graphics g) {
        g.drawImage(image, 0, 0, null);  // args: image, x, y, ImageObserver
    }

    public BufferedImage getBufferedImage() { return image; }

  } //// end nested class ImagePanel ///////////////////////

  ///////////////////////////////////////////////////////////
  ///// NESTED CLASS ImagePreview  //////////////////////////
  /* ImagePreview.java - used in Java tutorials under FileChooserDemo2.java. */
  public class ImagePreview extends JComponent implements PropertyChangeListener {
      ImageIcon thumbnail = null;
      File file = null;

      public ImagePreview(JFileChooser fc) {
          setPreferredSize(new Dimension(100, 50));
          fc.addPropertyChangeListener(this);
      }

      public void loadImage() {
          if (file == null) {
              thumbnail = null;
              return;
          }
          //Don't use createImageIcon (which is a wrapper for getResource)
          //because the image we're trying to load is probably not one
          //of this program's own resources.
          ImageIcon tmpIcon = new ImageIcon(file.getPath());
          if (tmpIcon != null) {
              if (tmpIcon.getIconWidth() > 90) {
                  thumbnail = new ImageIcon(tmpIcon.getImage().
                                            getScaledInstance(90, -1,
                                                        Image.SCALE_DEFAULT));
              } else { //no need to miniaturize
                  thumbnail = tmpIcon;
              }
          }
      } ///// end loadeImage() //////

      public void propertyChange(PropertyChangeEvent e) {
          boolean update = false;
          String prop = e.getPropertyName();

          //If the directory changed, don't show an image.
          if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) {
              file = null;
              update = true;
            //If a file became selected, find out which one.
          } else if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) {
              file = (File) e.getNewValue();
              update = true;
          }
          //Update the preview accordingly.
          if (update) {
              thumbnail = null;
              if (isShowing()) {
                  loadImage();
                  repaint();
              }
          }
      } //////// end propertyChange() //////////////

      protected void paintComponent(Graphics g) {
          if (thumbnail == null) {
              loadImage();
          }
          if (thumbnail != null) {
              int x = getWidth()/2 - thumbnail.getIconWidth()/2;
              int y = getHeight()/2 - thumbnail.getIconHeight()/2;

              if (y < 0) {    y = 0;        }
              if (x < 5) {    x = 5;        }
              thumbnail.paintIcon(this, g, x, y);
          }
      } /////// end paintComponent() //////////////
  } /////////// end nested class ImagePreview /////////////////////////////




  // resetComponents():  resets the form back to its original state so user starts with empty fields, etc
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="resetComponents()">
  public void resetComponents() {

    prosCount = 1;
    consCount = 1;

    nameField.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    nameField.setForeground(new java.awt.Color(140, 140, 140));
    nameField.setText("A word or short phrase describing this house");
    // a hack to get Java to stop overrighting my initial text an to stop it from automatically giving it focus
    nameField.setFocusable(true);

    priceField.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    priceField.setForeground(new java.awt.Color(140, 140, 140));
    priceField.setText("Show me the money!");
    
    summaryTextarea.setText("");

    // PRO #1
    proTitle1Field.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    proTitle1Field.setForeground(new java.awt.Color(140, 140, 140));
    proTitle1Field.setText("A word or short phrase describing this pro");

    proDetail1Textarea1.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    proDetail1Textarea1.setForeground(new java.awt.Color(140, 140, 140));
    proDetail1Textarea1.setText("A sentence or two providing details");

    // PRO #2
    proTitle2Field.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    proTitle2Field.setForeground(new java.awt.Color(140, 140, 140));
    proTitle2Field.setText("A word or short phrase describing this pro");

    proDetail2Textarea1.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    proDetail2Textarea1.setForeground(new java.awt.Color(140, 140, 140));
    proDetail2Textarea1.setText("A sentence or two providing details");

    // CON #1
    conTitle1Field.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    conTitle1Field.setForeground(new java.awt.Color(140, 140, 140));
    conTitle1Field.setText("A word or short phrase describing this con");

    conDetail1Textarea1.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    conDetail1Textarea1.setForeground(new java.awt.Color(140, 140, 140));
    conDetail1Textarea1.setText("A sentence or two providing details");

    // CON #2
    conTitle2Field.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    conTitle2Field.setForeground(new java.awt.Color(140, 140, 140));
    conTitle2Field.setText("A word or short phrase describing this con");

    conDetail2Textarea1.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    conDetail2Textarea1.setForeground(new java.awt.Color(140, 140, 140));
    conDetail2Textarea1.setText("A sentence or two providing details");



    // Make all the originally invisible components invisible again
    for(Component component: hideableCompVec) {
      component.setVisible(false);
    }

    // Make all the originially visible components that have been made invisible visible again
    for(Component component: startsVisibleCompVec ) {
      component.setVisible(true);
    }

  }// </editor-fold>



} /////////////////// end class AddItemForm ////////////////
